<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // vue中对数组重写的原理

      let originPrototype = Array.prototype
      let copyPrototype = Object.create(originPrototype) // copy

      Object.defineProperty(copyPrototype, 'splice', {
        enumerable: false,
        writable: true,
        configurable: true,
        value:function(){
          
          console.log('我是新的splice的方法')
        }
      })

      const arr = [1, 2, 3]
      arr.__proto__ = copyPrototype  
      arr.splice(1, 1)
      console.log(arr)
    </script>
  </body>
</html>
